package DB;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class ConnectToDB {

	private Connection mCon;
	
	public ConnectToDB(Properties p) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException{
		
		String Puser = p.getProperty("DBServer.user");
		String Ppassword = p.getProperty("DBServer.password");;
		String Purl = p.getProperty("DBServer.url");
		String PdbName = p.getProperty("DBServer.dbName");
		String Pdriver = p.getProperty("DBServer.driver");
		
	    // Load the Driver class. 
		Class.forName(Pdriver); 
		
		//Create the connection using the static getConnection method 
		mCon = DriverManager.getConnection (Purl+PdbName, Puser, Ppassword); 
	}
	
	public Connection getConnection() {
		return mCon;
	}

}

